<div class="home-news">
    <section class="auto-inner">
        <div class="home-title">
            <aside class="cn">公司业绩</aside>
        </div>
        <div class="tabs clearfix">
            <ul class="fr clearfix ul">
                <!-- 初始添加 on1 类到 performance 的 li -->
                <li class="on1"><a href="/news">更多业绩</a></li>
            </ul>
        </div>
        <div class="tabs-ul wow fadeInUp animated" style="visibility: visible; animation-name: fadeInUp;">
            <ul id="news-list" class="ul clearfix show">
                <!-- 动态加载内容将在此处插入 -->
            </ul>
        </div>
    </section>
</div>

<script>
    $(document).ready(function () {
        function loadNews() {
            $.ajax({
                url: '/api/three_news/latest/',
                method: 'GET',
                data: { type: 'performance' },
                success: function (data) {
                    let newsHtml = '';
                    data.forEach((news, index) => {
                        if (index === 0) {
                            newsHtml += `
                            <ol>
                                <a class="ytable fixed" href="/news/details/?news_id=${news.id}">
                                    <div class="ytable-cell pic">
                                        <figure class="Ispic" style="background-image: url(${news.cover_image_url});"><img src="${news.cover_image_url}" alt="${news.title}"></figure>
                                    </div>
                                    <div class="ytable-cell txt">
                                        <aside class="tit dot2">${news.title}</aside>
                                        <p class="dot4">${news.short_content}</p>
                                        <time>${news.publish_date}</time>
                                    </div>
                                </a>
                            </ol>
                        `;
                        } else {
                            newsHtml += `
                            <li>
                                <a class="ytable fixed" href="/news/details/?news_id=${news.id}">
                                    <div class="ytable-cell pic">
                                        <figure class="Ispic" style="background-image: url(${news.cover_image_url});"><img src="${news.cover_image_url}" alt="${news.title}"></figure>
                                    </div>
                                    <div class="ytable-cell txt">
                                        <aside class="tit dot2">${news.title}</aside>
                                        <p class="dot4">${news.short_content}</p>
                                        <time>${news.publish_date}</time>
                                    </div>
                                </a>
                            </li>
                        `;
                        }
                    });
                    $('#news-list').html(newsHtml);
                },
                error: function (error) {
                    console.error("Error fetching news:", error);
                }
            });
        }

        // 默认加载业绩信息，并设置初始激活状态
        loadNews();
        // 确保默认选项卡激活（如果HTML未预先添加）
    });
</script>